#!/usr/bin/env python

from sanic import Sanic
from sanic.response import json
import threading
from buildapk import makeApk
from buildapk import Task

app = Sanic()
task = Task()
task.init(makeApk)


@app.route("/build",methods=['POST'])
async def build(request):
    print (request)
    print ("isAlive = " + str(task.isAlive()))
    if not task.isAlive() :
       task.init(makeApk)
    task.add_task()
    print ("test")
    return json({"hello": "world"})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8088)
